package main;

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JTextArea;

import people.Character;
import constants.Exptable;

public class StatBoxFrame extends JFrame {

	private static final long serialVersionUID = -3745280229212199461L;

	JTextArea[] stats;
	String[] s = {"Experience: ", "Health: ", "Strength: ", "Dexterity: ", "Intellect: ", "Luck: "};
	
	public StatBoxFrame() {
		super("Adventure Land -- Stats");
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		initTextAreas();
		this.setLayout(new GridLayout(6, 1));
		this.setResizable(false);
		this.setSize(200, 300);
		this.setVisible(true);
	}

	private void initTextAreas() {
		setVisible(false);
		Character.c.initStats();
    	stats = new JTextArea[6];
    	for (int i = 0; i < 6; i++) {
    		stats[i] = new JTextArea();
		}
    	for (int i = 2; i < 6; i++) {
			stats[i].setText(s[i] + Character.c.stats[i]);
		}
    	stats[0].setText(s[0] + Character.c.exp + "/" + Exptable.exp[Character.c.level - 1]);
    	stats[1].setText(s[1] + Character.c.health + "/" + Character.c.stats[0]);
		addTextAreas();
		setVisible(true);
	}
	
	private void addTextAreas() {
		for (int i = 0; i < 6; i++) {
			add(stats[i]);
		}
	}
	
	public void recalcStats() {
		for (int i = 0; i < 6; i++) {
			remove(stats[i]);
		}
		initTextAreas();
	}
}
